<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>流程设置</title>
    <link rel="stylesheet" type="text/css" href="/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="/themes/icon.css">
    <link rel="stylesheet" type="text/css" href="/themes/cms.css">
    <link rel="stylesheet" type="text/css" href="/css/common.css">
    <script type="text/javascript" src="/js/jquery.min.js"></script>
    <script type="text/javascript" src="/js/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="/js/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript" src="/js/datagrid-transposedview.js"></script>
    <script type="text/javascript" src="/js/datagrid-detailview.js"></script>
</head>
<body>


<table id="prodefSet_dg" style="width:650px;height:250px"
       title="流程办理人设置"
       singleSelect="true" fitColumns="true">
    <thead>
    <tr>
        <th field="processDefId" width="80">流程ID</th>
        <th field="processDefName" width="100">流程名称</th>
    </tr>
    </thead>
</table>
<script type="text/javascript" src="/js/datagrid-cellediting.js"></script>
<script type="text/javascript">
    $(function () {
        $('#prodefSet_dg').datagrid({
            view: detailview,
            url: '/onBusiness/processDefList.do',
            idField: 'processDefId',
            detailFormatter: function () {
                return '<div style="padding:2px"><table class="ddv"></table></div>';
            },
            onExpandRow: function (index, row) {
                var ddv = $(this).datagrid('getRowDetail', index).find('table.ddv');
                ddv.datagrid({
                    url: '/onBusiness/taskDefList.do?processDefId=' + row.processDefId,
                    fitColumns: true,
                    singleSelect: true,
                    enableCellEditing: true,
                    rownumbers: false,
                    loadMsg: '',
                    height: 'auto',
                    onBeforeCellEdit: function () {
                        ddv.datagrid('acceptChanges');
                    },
                    onEndEdit: function () {
                        var rows = ddv.datagrid('getChanges');
                        if(rows.length>0){
                            var task= JSON.stringify(rows[0]);
                        $.post('/onBusiness/ProcdefAssignee.do',{task:task,processDefId:row.processDefId});
                        }
                    },
                    columns: [[
                        {field: 'taskId', title: '任务ID', width: 200},
                        {field: 'taskName', title: '任务名称', width: 100, align: 'right'},
                        {field: 'assignee', title: '指定办理人', width: 100, align: 'right', editor: 'text'}
                    ]],
                    onResize: function () {
                        $('#prodefSet_dg').datagrid('fixDetailRowHeight', index);
                    },
                    onLoadSuccess: function () {
                        setTimeout(function () {
                            $('#prodefSet_dg').datagrid('fixDetailRowHeight', index);
                        }, 0);
                    }
                });
                ddv.datagrid('enableCellEditing');
                $('#prodefSet_dg').datagrid('fixDetailRowHeight', index);
            }
        });
    });

</script>

<script>

    function onEndEdit() {
        if (endEditing()) {
            $('#dg').datagrid('acceptChanges');
        }
        var rows = $('#dg').datagrid('getChanges');
        alert(rows.length + ' rows are changed!');
    }
</script>
</body>
</html>